//index.js
//获取应用实例
const app = getApp()
// console.log(app);

Page({
    data: {
        dot: true,
        autopaly: true,
        time: 5000,
        loops:[],
        products:[]
    },
    onLoad:function(){
        this.loadLoopData();
        this.loadProductList();
    },
    loadLoopData:function(){
        wx.request({
            url: 'https://oa.itany.com/exchange/loop/findAllLoop',
            method: 'POST',
            success: ({statusCode,data})=>{
                // console.log(data);
                if(statusCode==200){
                    this.setData({
                        loops:data
                    });
                }
            },
            fail: (error)=>{
                console.log(error);
            },
        });
    },
    loadProductList(){
        wx.request({
            url: 'https://oa.itany.com/exchange/articlelist/findArticleList',
            data: {
                page:1,
                rows:4
            },
            header: {'content-type':'application/x-www-form-urlencoded'},
            method: 'POST',
            success: ({statusCode,data})=>{
                // console.log(data);
                if(statusCode==200){
                    this.setData({
                        products:data.rows
                    });
                }
            },
            fail: (error)=>{
                console.log(error);
            },
        });
    }

})
